package com.itheima;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;

public class Demo03 {
    public static void main(String[] args) {
        between1();
    }

    //两个时间的间隔 开始 -  结束
    public static void between1() {
        LocalDate deTime = LocalDate.of(2020, 6, 13);
        LocalDate deTime1 = LocalDate.of(2042, 6, 13);
        Period period = Period.between(deTime, deTime1);
        System.out.println(period);
        //public int getYears()         获得这段时间的年数
        System.out.println(period.getYears());//28
        //public int getMonths()        获得此期间的月数
        System.out.println(period.getMonths());//11
        //public int getDays()          获得此期间的天数
        System.out.println(period.getDays());//11

        //public long toTotalMonths()   获取此期间的总月数
        System.out.println(period.toTotalMonths());//347
    }


}
